package com.fengye.algorithms.leecode;

/**
 * @Author fengye
 * @Date 2023/4/8 11:41
 **/
public class RotateArray189 {
    public void rotate(int[] nums, int k) {
        int n = nums.length;
        if(k==0 || k == n) {
            return;
        }

        if(k>n) {
            k = k % n;
        }

        int[] arr = new int[k];
        System.arraycopy(nums, n-k, arr,0, k);
        System.arraycopy(nums, 0, nums, k, n-k);
        System.arraycopy(arr,0, nums,0,k);
    }
}
